<template lang="jade">
div
	h-loader-full(url='loader',:setdata='false')
	h-data-updater(url='edit/job')
		m-title(icon='add',name='职位管理>职位详情')
		table.single
			mf-row(name='公司名称：') {{data.cname}}
			mf-row(name='岗位名称：') {{data.jobname}}
			mf-row(name='薪资水平：',msg='必填') {{data.pay}}
			mf-row(name='工作区域：',msg='必填') {{data.area}}
			mf-row(name='发布时间：',msg='必填') {{new Date(data.time_create*1000).format('yyyy-MM-dd hh:mm:ss')}}
			mf-row(name='福利待遇：') 
				p {{data.benefit}}
			mf-row(name='学历要求：',msg='必填') {{data.education}}
			mf-row(name='经验要求：',msg='必填') {{data.experience}}
			mf-row(name='工作地址：',msg='必填') {{data.address}}
			mf-row(name='岗位职责：',msg='必填') {{data.statement}}
			mf-row(name='审核状态：',msg='必填') {{type[data.status_check]}}
			mf-row(name='失败原因：',msg='如失败则需要填写',v-show='data.status_check==0'): input(type='text',v-model='data.reason')
			mf-row(name='')
				input(type='button',value='审核成功',@click='examine(1)')
				input(type='button',value='审核失败',@click='examine(2)')
			mf-row(name='')
				button(id='button') 确认提交
</template>
<script>
export default {
	data () {
		return {
			loader: {
				data:'job/detail/' + this.$query.get('id'),
				experience:'experience/list',
				pay:'pay/list',
				benefit:'benefit/list',
				education:'education/list',
				jobtype:'jobtype/list',
				area:'area/list'
			},
			data: {
				reason:'',
			},
			reason:'',
			jtid:{
				bid:0,
				mid:0,
				sid:0
			},
			type:['待审核','审核成功','审核失败'],
			experience:[],
			com_type:[{id:1,name:'央企'},{id:2,name:'国企'},{id:0,name:'其他'}],
			pay:[],
			benefit:[],
			education:[],
			jobtype:[],
			area:[],
			big:[],
			middle:[],
			small:[]
		}
	},
	methods: {
		loadAfter(data){
			this.data = data.data
			this.experience = data.experience
			this.pay=data.pay
			this.benefit=data.benefit
			this.education = data.education
			this.jobtype = data.jobtype
			for(let v of this.jobtype){
        if(v.bid == 0){
          this.big.push(v)
        }
      }
			for(let n of this.benefit){
        for(let bene of this.data.benefit.split('|')){
          if(n.name == bene){
            n.checked = true
          }
        }
      }
			this.area = data.area
		},
		check(i,type){
      if(type){
        this.benefit[i].checked=false
      }else{
        this.benefit[i].checked=true
      }
    },
		updateBefore(){
			let a=''
      let b= ''
      for(let v of this.benefit){
        if(v.checked==true){
          a += v.name +'|'
          b = a.substring(0,a.length-1)
        }
      }
      this.data.benefit = b
			return true
		},
		examine(examine){
			if(this.data.reason == 'undefined'){
				this.data.reason = ''
			}
			this.$ajax.put('job/examine',{'id':this.data.id,'examine':examine,'reason':this.data.reason},(res)=>{
				this.$msg.success('操作成功')
				window.location.href='job.html?examine=0'    
			},(res)=>{
				this.$msg.error(res.message)
			})	
		}
	},
}

</script>
<style lang="less" scoped>
@import "../../../plugin/style/mixin";
.be {
	 .mlr(5);.bsol(#f0f0f0);
}
.bg{
	.bk(#ee5)
}
.top{
	.c(red);
}

</style>